package com.bbx.taxi.client.Activity.Menu;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.OnClick;

import com.bbx.api.sdk.Config;
import com.bbx.api.sdk.net.base.HttpComm;
import com.bbx.taxi.client.R;
import com.bbx.taxi.client.Activity.Base.BaseBBXActivity;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Bean.Extra.SetMsg;
import com.bbx.taxi.client.Util.ChannelName;
import com.bbx.taxi.client.Util.VersionInfo;
import com.bbx.taxi.client.Util.VersionUtils;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog.onClickSingleListener;

public class AboutActivity extends BaseBBXActivity {
	@Bind(R.id.tv_version)TextView tv_version;
	@Bind(R.id.iv_pubiao)ImageView iv_pubiao;
    @Bind(R.id.tv_telkf)TextView tv_telkf;
    @Bind(R.id.tv_mail)TextView tv_mail;
    @Bind(R.id.tv_xi)TextView tv_xi;
    @Bind(R.id.tv_nan)TextView tv_nan;
    @Bind(R.id.tv_dong)TextView tv_dong;
    @Bind(R.id.tv_zhong)TextView tv_zhong;
    @Bind(R.id.tv_bei)TextView tv_bei;
    @Bind(R.id.tv_qita)TextView tv_qita;
	protected void onCreate(Bundle savedInstanceState) {

		setContentView(R.layout.acticity_about);
		super.onCreate(savedInstanceState);
	
	}

	@Override
	protected void initView() {
		setTitle(R.string.app_introduce);
		switch(VersionUtils.getVersionType(context)){
		case bbx:
			tv_telkf.setText(Value.TEL_KF);
			tv_mail.setText("kefu@bbxpc.com");
			break;
		case tianshang:
			tv_telkf.setText(Value.TEL_TSX);
			tv_mail.setText("kef@bbxpc.com");
			break;
		}
		tv_version.setText(String.format(getString(R.string.text_version), VersionInfo.getVersion(this)));
		/////////////////////////////
		iv_pubiao.setOnLongClickListener(new OnLongClickListener() {
			@Override
			public boolean onLongClick(View v) {
				final MyAlertDailog dialog = new MyAlertDailog(AboutActivity.this);
				String huanjing = "";
				switch(Config.getInstance().Env){
				case 0:
					huanjing="环境：开发";
					break;
				case 1:
					huanjing="环境：测试";
					break;
				case 2:
					huanjing="环境：正式";
					break;
				}
				dialog.setTitle(huanjing);
//				dialog.setContent(huanjing+"\n域名："+HttpComm.BASE_URL+"\n"+"TCP IP:"+Config.IP+"\nTCP端口："+Config.PORT+"\n渠道编号："+ChannelName.getAppMetaData(AboutActivity.this));
				dialog.setContent(huanjing+"\n渠道编号："+ChannelName.getAppMetaData(AboutActivity.this));
				dialog.setSingle(getString(R.string.mydailog_know));
				dialog.show();
				dialog.setOnClickSingleListener(new onClickSingleListener() {
					@Override
					public void onClickSingle() {
						dialog.dismiss();
					}
				});
				return false;
			}
		});
	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub

	}
	@OnClick({ R.id.tv_xi,R.id.tv_nan,R.id.tv_dong,R.id.tv_zhong,R.id.tv_bei,R.id.tv_qita,R.id.tv_telkf})
	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.tv_xi:
		case R.id.tv_nan:
		case R.id.tv_dong:
		case R.id.tv_zhong:
		case R.id.tv_bei:
		case R.id.tv_qita:
			onTeljiaMeng((TextView)v);
		break;
		case R.id.tv_telkf:
			// 用intent启动拨打电话
			context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
					+ tv_telkf.getText().toString())));
			break;
		 default:
				super.onClick(v);
			 break;
		}

	}
	public void onTeljiaMeng(TextView v){
		String text=v.getText().toString();
		if(text!=null&&text.length()>6){
			text=text.substring(6,text.length());
		}
		// 用intent启动拨打电话
		context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
				+ text)));
	}
	
}
